
#import "Bottle_GameResult.h"
#import "GameConfig.h"

@implementation Bottle_GameResult

+(CCScene*)scene
{
	// 'scene' is an autorelease object.
	CCScene *scene = [CCScene node];
	
	// 'layer' is an autorelease object.
	Bottle_GameResult *layer = [Bottle_GameResult node];
	
	// add layer as a child to scene
	[scene addChild: layer];
	
	// return the scene
	return scene;
}

-(void)Bottle_GameResult_Again:(id)sender
{
	if(delegate)
	{
		[delegate Bottle_GameResultSelected:EBottle_GameResult_Again];
	}
}

-(void)Bottle_GameResult_Return:(id)sender
{
	if(delegate)
	{
		[delegate Bottle_GameResultSelected:EBottle_GameResult_Return];
	}
}

-(void)Bottle_GameResult_Des:(id)sender
{
	if(delegate)
	{
		[delegate Bottle_GameResultSelected:EBottle_GameResult_Des];
	}
}

-(id)init:(id<Bottle_GameResultDelegate>) _delegate
{
	self = [super init];
	if (self)
	{
		delegate = _delegate;
		
		//CGSize size = [[CCDirector sharedDirector] winSize];
	
		//底部背景
		CCSprite *bottomBg=[CCSprite spriteWithFile:@"bottom_bg.png"];
		bottomBg.position = ccp(SCREEN_WIDTH/2,BOTTOM_HEIGHT);
		[self addChild:bottomBg];
		
		//惩罚说明
		CCSprite *gamedes=[CCSprite spriteWithFile:@"punishdes.png"];
		gamedes.position = ccp(SCREEN_WIDTH/2,SCREEN_HEIGHT - 40);
		[self addChild:gamedes];
		
		//
		NSArray *resultArray=[NSArray arrayWithObjects:
							  @"闭眼10秒，其他人可随意调换位置，10秒后猜正对面的人是谁",
							  @"含一口酒，下一轮游戏不能说话",
							  @"品尝其他的人酒一口，5秒内说出其中的3种配料",
							  @"含一口酒，用鼻子吹气吹灭蜡烛",
							  @"在场有蓝色服装或者蓝色配饰的人之外，喝一杯酒",
							  @"在背后写字，需要猜正确",
							  @"摆鬼脸6连拍",
							  @"10秒内讲出3部奥斯卡获奖影片（下一轮不可重复影片名）",
							  @"蒙住眼睛，靠手触摸猜出对方",
							  @"失败者买一杯使用法国灰雁特调的鸡尾酒给胜利者",
							  @"失败者使用各种方式在30秒内搏胜利者一笑",
							  @"胜利者指定一名玩家，失败者哼着小曲与其对视10秒",
							  @"胜利者指定在场任意一人，失败者与其打招呼",
							  @"失败者选择任意两名玩家的饮料，取少量加入自己的饮料",
							  @"失败者与胜利者指定的玩家拥抱3秒",
							  @"失败者至下轮游戏结束前保持微笑",
							  @"失败者双手放背后饮一口自己的酒",
							  @"胜利者可选择喝一口失败者的酒或让对方喝一口自己的酒",
							  @"失败者喂胜利者饮一口酒",
							  nil];
		
		int num = arc4random()%[resultArray count];
		
		CCLabelTTF* label = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"您可自定义惩罚内容，也可以使用一下惩罚建议:\r\n\r\n\r\n%@",[resultArray objectAtIndex:num]]
											 dimensions:CGSizeMake(220,300) alignment:CCTextAlignmentLeft 
											   fontName:@"Arial" fontSize:16];
		[label setPosition: ccp(162,230)];
		[self addChild: label z:1];
		
		
		//提示框
		CCSprite *tipBg=[CCSprite spriteWithFile:@"tipFrame.png"];
		tipBg.position = ccp(SCREEN_WIDTH/2,SCREEN_HEIGHT/2);
		[self addChild:tipBg];
		
		//返回
		CCMenuItemImage *vm = [CCMenuItemImage itemFromNormalImage:@"back_icon.png" selectedImage:nil target:self selector:@selector(Bottle_GameResult_Return:)];	
		CCMenu *vmm = [CCMenu menuWithItems: vm, nil];
		vmm.position = ccp(BOTTOM_X, BOTTOM_HEIGHT);
		[self addChild:vmm z:2];
		
		//再来一次
		CCMenuItemImage *selectedMenu = [CCMenuItemImage itemFromNormalImage:@"onemore.png" selectedImage:@"onemore_down.png" target:self selector:@selector(Bottle_GameResult_Again:)];
		CCMenu *menu = [CCMenu menuWithItems:selectedMenu, nil];
		menu.position = ccp(SCREEN_WIDTH/2,BOTTOM_HEIGHT);
		[self addChild:menu];
		
		//help
		
		CCMenuItemImage *help = [CCMenuItemImage itemFromNormalImage:@"help_icon.png" selectedImage:nil target:self selector:@selector(Bottle_GameResult_Des:)];	
		CCMenu *helpMenu = [CCMenu menuWithItems: help, nil];
		helpMenu.position = ccp(SCREEN_WIDTH - BOTTOM_X , BOTTOM_HEIGHT);
		[self addChild:helpMenu z:2];
		
	}
	
	return self;
}

- (void)layerReplaced
{
	
}

@end
